/**
 * @title HHUserAction.java 
 * @description 	后台用户管理模块动作类文件
 * @create 			2012-7-26 上午10:35:17 By xjiujiu
 * @package 		apps.admin.action
 * @copyright 		Copyright (c) 2011-2012 http://xyrj.hhtc.edu.cn.com. All right reserved
 * @version        $Id$
 * XYRJ-Java-Project
 */

package apps.admin.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import system.pojo.HHNewsmesPojo;

import apps.admin.form.HHNewsmesForm;
import apps.admin.model.HHNewsmesModel;
import apps.admin.model.HHModelBaseModel;

import com.xyrj.exception.HHValidateException;
import com.xyrj.mvc.HHAction;
import com.xyrj.utils.HHDatetime;

/** 
 * 企业后台管理模块动作类
 * 留言模块
 * @description
 * 
 * @classname 	HHUserAction 
 * @author 		xjiujiu<xjiujiu@foxmail.com>
 * @date 		2012-7-26 上午10:35:17 
 * @version 	1.0
 */
public class HHNewsmesAction extends HHActionBaseAction
{

	/** 
     * @see HHAction#HHAction(HttpServletRequest, HttpServletResponse)
     */
    public HHNewsmesAction(HttpServletRequest request, HttpServletResponse response)
    {
	    super(request, response);
	    
	    this._pojo 		= new HHNewsmesPojo();
    }
   
    /**
     * @see HHActionBaseAction#addview()
     */
    public void addview()
    {
    	super.addview();
    	this._assignParentList(new HHNewsmesModel());
    	
    	this._view.display("admin/teachmes/info.jsp");
    }
   
    /**
     * 添加用户动作
     *  
     * @description
     * 
     * @title  add
     * @return void
     */
    public void add()
    { 
    	try {
	    	this._assginPojoByAdd();
	    	HHNewsmesForm 	addTeachmesForm = new HHNewsmesForm();
	    	addTeachmesForm.validate(this._pojo);
	    	this._pojo.setField("edit_time", HHDatetime.getNow());
	    	this._pojo.setField("create_time", HHDatetime.getNow());
	    	this._pojo.setField("author", this._view.getSessionAttr("xyrj_user_name"));
	    	HHNewsmesModel teachmesModel 		= this._initModel();
	    	if(0 <  teachmesModel.add(this._pojo)) {
	    		this._view.alertAndGoBack("添加成功");
	    	} else {
	    		this._view.alertAndGoBack("添加失败！请联系管理员～");
	    	}
    	} catch (HHValidateException ex) {
    		this._view.alertAndGoBack(ex.getMessage());
    	}
	}
   
    /**
     * @see HHActionBaseAction#editview()
     */
    public void editview()
    {
    	super.editview();
    	this._assignParentList(new HHNewsmesModel());

    	this._view.display("admin/teachmes/info.jsp");
    }
   
    /**
     * 提交用户修改
     *  
     * @description
     * 
     * @title  edit
     * @return void
     */
    public void edit()
    {
    	try {
	    	this._assginPojoByEdit();
	    	HHNewsmesForm 	editTeachmesForm = new HHNewsmesForm();
	    	editTeachmesForm.validate(this._pojo);
	    	this._pojo.setField("edit_time", HHDatetime.getNow());
	    	this._pojo.setField("author", this._view.getSessionAttr("xyrj_user_name"));
	    	HHNewsmesModel teachmesModel 		= this._initModel();
	    	if(0 <  teachmesModel.edit(this._pojo)) {
	    		this._view.alertAndRefresh("更新成功");
	    	} else {
	    		this._view.alertAndRefresh("更新失败！请联系管理员～");
	    	}
    	} catch (HHValidateException ex) {
    		this._view.alertAndGoBack(ex.getMessage());
    	}
    }
   
    /**
     * @see HHModelBaseModel#initModel()
     */
    protected HHNewsmesModel _initModel()
    {
    	return new HHNewsmesModel(this._pojo);
    }

	/* (非 Javadoc) 
     * <p>初始化当前模块的父类模块实例</p>
     * 
     * <p>description: </p> 
     *
     * @title _initParentModel 
     * @return 
     * @see apps.admin.action.HHActionBaseAction#_initParentModel() 
     */
    @Override
    protected HHNewsmesModel _initParentModel()
    {
	    return new HHNewsmesModel();
    }
    
}
